package oop第一章作业;
import java.util.Scanner;

public class Visitof {
    String name;
    int age;
    Scanner input=new Scanner(System.in);
    void  visitor(){
        boolean s=true;
        do {
            System.out.println("请输入姓名");
            this.name=input.next();

            System.out.println("请输入年龄");
            this.age=input.nextInt();
            if (this.age>=18&&this.age<=60){
                System.out.println(this.name+"的年龄为："+this.age+"门票价格为：20元");
            }else {
                System.out.println(this.name+"的年龄为："+this.age+"门票免费");
            }
            System.out.println("是否继续（y/n）");
            String  y=input.next();
            if (y.equals("y")){
                 s=true;
            }else {
                s = false;
            }
        }while (s);
    }

    public static void main(String[] args) {
        Visitof buy= new Visitof();
        buy.visitor();
    }
}
